﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:v="clr-namespace:ShredTheLog.Views;assembly=ShredTheLog.Views"
    xmlns:vm="clr-namespace:ShredTheLog.ViewModels;assembly=ShredTheLog.ViewModels"
    xmlns:cnv="clr-namespace:ShredTheLog.Converters;assembly=ShredTheLog.Converters"
    xmlns:c="clr-namespace:ShredTheLog.Controls;assembly=ShredTheLog.Controls"
    >

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="OdigoMisc2.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    
    <DataTemplate x:Key="UserProfileContentTemplate" DataType="{x:Type vm:UserProfileViewModel}">
        <DataTemplate.Resources>
            <Style x:Key="LabelStyle" TargetType="{x:Type TextBlock}">
                <Setter Property="Foreground" Value="#FCFDF9"/>
                <Setter Property="Margin" Value="8, 0, 2, 0"/>
                <Setter Property="TextWrapping" Value="Wrap"/>
            </Style>
            
            <Style x:Key="ValueStyle" TargetType="{x:Type TextBlock}">
                <Setter Property="Foreground" Value="#D4DEE9"/>
                <Setter Property="Margin" Value="8, 0, 0, 0"/>
                <Setter Property="TextWrapping" Value="Wrap"/>
            </Style>
            
            <Style x:Key="MultiStringValueStyle" TargetType="{x:Type TextBox}">
                <Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
                <Setter Property="Foreground" Value="White"/>
                <Setter Property="Background" Value="#6B89BD"/>
                <Setter Property="TextWrapping" Value="Wrap"/>
                <Setter Property="IsReadOnly" Value="True"/>
                <Setter Property="Margin" Value="0, 2, 16, 2"/>
            </Style>

            <Style TargetType="{x:Type c:TranslationRun}">
                <Setter Property="FontStyle" Value="{x:Static FontStyles.Italic}"/>
                <Setter Property="Foreground" Value="#40FFFFFF"/>
            </Style>
        </DataTemplate.Resources>

        <!--Темно-серая панель с основным содержимым окна-->
        <Grid x:Name="panel">
            <Border x:Name="roundedBorder" BorderBrush="{StaticResource BlackBorderBrush}" BorderThickness="1" CornerRadius="4" Background="{StaticResource GrayPanelBackgroundBrush}">
                <Grid Grid.Row="0">
                    <UIElement.Clip>
                        <MultiBinding Converter="{x:Static cnv:RectangleGeometryConverter.Default}">
                            <Binding ElementName="roundedBorder" Path="ActualWidth"/>
                            <Binding ElementName="roundedBorder" Path="ActualHeight"/>
                            <Binding ElementName="roundedBorder" Path="CornerRadius.BottomLeft"/>
                            <Binding ElementName="roundedBorder" Path="BorderThickness.Left"/>
                        </MultiBinding>
                    </UIElement.Clip>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <Grid Grid.Row="0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="3*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Text="{Binding FirstName}" Foreground="#D4DEE9" FontWeight="Bold" FontSize="18" Margin="12, 0, 2, 0"/>
                        
                        <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource LabelStyle}">
                            <Run Text="{c:LocalizedString s_Name}"/><Run Text=":     "/>
                        </TextBlock>
                        <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Name}" Style="{StaticResource ValueStyle}"/>

                        <TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource LabelStyle}">
                            <Run Text="{c:LocalizedString s_ID}"/><Run Text=":     "/>
                        </TextBlock>
                        <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Uid}" Style="{StaticResource ValueStyle}"/>
                    </Grid>

                    <TabControl Grid.Row="1" Margin="0, 4, 0, 0" Background="{StaticResource GrayPanelBackgroundBrush}" IsSynchronizedWithCurrentItem="True">
                        <TabControl.Template>
                            <ControlTemplate TargetType="{x:Type TabControl}">
                                <DockPanel Margin="{TemplateBinding Margin}" Background="{TemplateBinding Background}">
                                    <Grid DockPanel.Dock="Top">
                                        <Border BorderThickness="0, 0, 0, 1" BorderBrush="#9596A6"/>
                                        <Border DockPanel.Dock="Top" KeyboardNavigation.TabNavigation="Local">
                                            <TabPanel x:Name="HeaderPanel" Margin="4,0,4,0" IsItemsHost="true" Panel.ZIndex="1" Grid.Column="1" KeyboardNavigation.TabIndex="1"/>
                                        </Border>
                                    </Grid>
                                    <Border x:Name="ContentPanel" Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="1" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
                                        <ContentPresenter x:Name="PART_SelectedContentHost" Margin="{TemplateBinding Padding}" ContentSource="SelectedContent"/>
                                    </Border>
                                </DockPanel>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsEnabled" Value="false">
                                        <Setter Property="Foreground" Value="Gray"/>
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </TabControl.Template>

                        <TabControl.ItemContainerStyle>
                            <Style TargetType="{x:Type TabItem}">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                                <Setter Property="Foreground" Value="#FCFDF9"/>
                                <Setter Property="MinWidth" Value="75"/>
                                <Setter Property="Padding" Value="4, 1, 4, 5"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type TabItem}">
                                            <Grid MinWidth="{TemplateBinding MinWidth}">
                                                <Border x:Name="border" Margin="0, 2, 1, 0" Background="#45414B" Padding="{TemplateBinding Padding}">
                                                    <ContentPresenter HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" RecognizesAccessKey="True" ContentSource="Header"/>
                                                </Border>
                                                <Border x:Name="topBorder" Margin="0, 2, 1, 0" CornerRadius="4, 4, 0, 0" BorderThickness="1, 1, 1, 0" BorderBrush="#0B0D10">
                                                    <UIElement.Effect>
                                                        <DropShadowEffect Direction="90" ShadowDepth="1" Color="Black" Opacity="1" BlurRadius="3"/>
                                                    </UIElement.Effect>
                                                </Border>
                                                <Border x:Name="bottomBorder" BorderThickness="0, 0, 0, 1" BorderBrush="#9596A6">
                                                    <UIElement.Effect>
                                                        <DropShadowEffect Direction="90" ShadowDepth="1" Color="Black" Opacity="1" BlurRadius="3"/>
                                                    </UIElement.Effect>
                                                </Border>
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsSelected" Value="True">
                                                    <Setter TargetName="border" Property="Background" Value="{StaticResource GrayPanelBackgroundBrush}"/>
                                                    <Setter TargetName="topBorder" Property="BorderBrush" Value="#9596A6"/>
                                                    <Setter TargetName="bottomBorder" Property="BorderBrush" Value="Transparent"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </TabControl.ItemContainerStyle>

                        <!--Закладка General-->
                        <TabItem Header="{c:LocalizedString s_General}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="2*"/>
                                </Grid.ColumnDefinitions>

                                <TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource LabelStyle}"><Run Text="{c:LocalizedString s_Age}"/>:</TextBlock>
                                <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Age}" Style="{StaticResource ValueStyle}"/>

                                <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource LabelStyle}"><Run Text="{c:LocalizedString s_Gender}"/>:</TextBlock>
                                <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Path=Gender, Converter={x:Static cnv:GenderConverter.Default}}" Style="{StaticResource ValueStyle}"/>

                                <TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource LabelStyle}"><Run Text="{c:LocalizedString s_UserIn}"/>:</TextBlock>
                                <TextBlock Grid.Row="2" Grid.Column="1" Style="{StaticResource ValueStyle}">
                                        <TextBlock.Text>
                                            <MultiBinding Converter="{x:Static cnv:UserLocationConverter.Default}">
                                                <Binding Path="Country"/>
                                                <Binding Path="Location"/>
                                            </MultiBinding>
                                        </TextBlock.Text>
                                </TextBlock>

                                <TextBlock Grid.Row="3" Grid.Column="0" Style="{StaticResource LabelStyle}">
                                        <Run Text="{c:LocalizedString s_NativeLanguages}"/>:
                                </TextBlock>
                                <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Path=KnownLanguages, Mode=OneWay, Converter={x:Static cnv:LanguagesConverter.Default}}" Style="{StaticResource MultiStringValueStyle}"/>

                                <TextBlock Grid.Row="4" Grid.Column="0" Style="{StaticResource LabelStyle}">
                                        <Run Text="{c:LocalizedString s_PracticingLanguages}"/>:
                                </TextBlock>
                                <TextBox Grid.Row="4" Grid.Column="1" Text="{Binding Path=PracticingLanguages, Mode=OneWay, Converter={x:Static cnv:LanguagesConverter.Default}}" Style="{StaticResource MultiStringValueStyle}"/>
                            </Grid>
                        </TabItem>

                        <!--Закладка More-->
                        <TabItem Header="{c:LocalizedString s_More}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="2*"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>

                                <TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource LabelStyle}"><Run Text="{c:LocalizedString s_RegisteredSince}"/>:</TextBlock>
                                <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding RegistrationDate}" Style="{StaticResource ValueStyle}"/>

                                <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource LabelStyle}"><Run Text="{c:LocalizedString s_Emails}"/>:</TextBlock>
                                <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Path=ExchangesEmails, Converter={x:Static cnv:YesNoConverter.Default}}" Style="{StaticResource ValueStyle}"/>

                                <TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource LabelStyle}"><Run Text="{c:LocalizedString s_Chats}"/>:</TextBlock>
                                <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Path=ChatsOnline, Converter={x:Static cnv:YesNoConverter.Default}}" Style="{StaticResource ValueStyle}"/>

                                <TextBlock Grid.Row="3" Grid.Column="0" Style="{StaticResource LabelStyle}"><Run Text="{c:LocalizedString s_UserStatus}"/>:</TextBlock>
                                <TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding Status}" Style="{StaticResource ValueStyle}"/>
                            </Grid>
                        </TabItem>

                        <!--Закладка Comments-->
                        <TabItem Header="{c:LocalizedString s_Comments}">
                            <FlowDocumentScrollViewer Foreground="#D4DEE9" VerticalScrollBarVisibility="Auto" Document="{Binding Path=Description, Converter={x:Static vm:UserDescriptionConverter.Default}}" c:Extensions.UnbindDocumentWhenSettingsUpdated="True"/>
                        </TabItem>
                    </TabControl>
                </Grid>
            </Border>

            <!--Картинка-аватар-->
            <Border HorizontalAlignment="Right" VerticalAlignment="Top" Background="{StaticResource BlueWindowBackgroundBrush}" Padding="2, 0, 0, 2">
                <Border x:Name="imageBorder" BorderBrush="#040304" BorderThickness="1" CornerRadius="2">
                    <Image Source="{Binding Path=Model, Converter={x:Static cnv:OdigoAvatarConverter.Default}}" Stretch="None">
                        <UIElement.Clip>
                            <MultiBinding Converter="{x:Static cnv:RectangleGeometryConverter.Default}">
                                <Binding ElementName="imageBorder" Path="ActualWidth"/>
                                <Binding ElementName="imageBorder" Path="ActualHeight"/>
                                <Binding ElementName="imageBorder" Path="CornerRadius.BottomLeft"/>
                                <Binding ElementName="imageBorder" Path="BorderThickness.Left"/>
                            </MultiBinding>
                        </UIElement.Clip>
                    </Image>
                </Border>
            </Border>
        </Grid>

        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsLoading}" Value="true">
                <Setter TargetName="panel" Property="Cursor" Value="Wait"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate DataType="{x:Type vm:UserProfileViewModel}">
        <ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource UserProfileContentTemplate}"/>
    </DataTemplate>
</ResourceDictionary>